<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><link href="http://search.cpan.org/s/style.css" rel="stylesheet" type="text/css">
<title>GeoConvert(1)</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>

<body>



<h1 id="NAME">NAME</h1>

<p>GeoConvert -- convert geographic coordinates</p>

<h1 id="SYNOPSIS">SYNOPSIS</h1>

<p><b>GeoConvert</b> [ <b>-g</b> | <b>-d</b> | <b>-:</b> | <b>-u</b> | <b>-m</b> | <b>-c</b> ] [ <b>-z</b> <i>zone</i> | <b>-s</b> | <b>-t</b> | <b>-S</b> | <b>-T</b> ] [ <b>-n</b> ] [ <b>-w</b> ] [ <b>-p</b> <i>prec</i> ] [ <b>-l</b> | <b>-a</b> ] [ <b>--comment-delimiter</b> <i>commentdelim</i> ] [ <b>--version</b> | <b>-h</b> | <b>--help</b> ] [ <b>--input-file</b> <i>infile</i> | <b>--input-string</b> <i>instring</i> ] [ <b>--line-separator</b> <i>linesep</i> ] [ <b>--output-file</b> <i>outfile</i> ]</p>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p><b>GeoConvert</b> reads from standard input interpreting each line as a geographic coordinate and prints the coordinate in the format specified by the options on standard output. The input is interpreted in one of three different ways depending on how many space or comma delimited tokens there are on the line. The options <b>-g</b>, <b>-d</b>, <b>-u</b>, and <b>-m</b> govern the format of output. In all cases, the WGS84 model of the earth is used (<i>a</i> = 6378137 m, <i>f</i> = 1/298.257223563).</p>

<dl>

<dt id="geographic"><b>geographic</b></dt>
<dd>

<p>2 tokens (output options <b>-g</b>, <b>-d</b>, or <b>-:</b>) given as <i>latitude</i> <i>longitude</i> using decimal degrees or degrees, minutes, and seconds. Latitude is given first (unless the <b>-w</b> option is given). See <a href="#GEOGRAPHIC-COORDINATES">&quot;GEOGRAPHIC COORDINATES&quot;</a> for a description of the format. For example, the following are all equivalent</p>

<pre><code>    33.3 44.4
    E44.4 N33.3
    33d18&#39;N 44d24&#39;E
    44d24 33d18N
    33:18 +44:24</code></pre>

</dd>
<dt id="UTM-UPS"><b>UTM/UPS</b></dt>
<dd>

<p>3 tokens (output option <b>-u</b>) given as <i>zone</i>+<i>hemisphere</i> <i>easting</i> <i>northing</i> or <i>easting</i> <i>northing</i> <i>zone</i>+<i>hemisphere</i>, where <i>hemisphere</i> is either <i>n</i> (or <i>north</i>) or <i>s</i> (or <i>south</i>). The <i>zone</i> is absent for a UPS specification. For example,</p>

<pre><code>    38n 444140.54 3684706.36
    444140.54 3684706.36 38n
    s 2173854.98 2985980.58
    2173854.98 2985980.58 s</code></pre>

</dd>
<dt id="MRGS"><b>MRGS</b></dt>
<dd>

<p>1 token (output option <b>-m</b>) is used to specify the center of an MGRS grid square. For example,</p>

<pre><code>    38SMB4484
    38SMB44140847064</code></pre>

</dd>
</dl>

<h1 id="OPTIONS">OPTIONS</h1>

<dl>

<dt id="g"><b>-g</b></dt>
<dd>

<p>output latitude and longitude using decimal degrees. Default output mode.</p>

</dd>
<dt id="d"><b>-d</b></dt>
<dd>

<p>output latitude and longitude using degrees, minutes, and seconds (DMS).</p>

</dd>
<dt id="pod"><b>-:</b></dt>
<dd>

<p>like <b>-d</b>, except use : as a separator instead of the d, &#39;, and &quot; delimiters.</p>

</dd>
<dt id="u"><b>-u</b></dt>
<dd>

<p>output UTM or UPS.</p>

</dd>
<dt id="m"><b>-m</b></dt>
<dd>

<p>output MGRS.</p>

</dd>
<dt id="c"><b>-c</b></dt>
<dd>

<p>output meridian convergence and scale for the corresponding UTM or UPS projection. The meridian convergence is the bearing of grid north given as degrees clockwise from true north.</p>

</dd>
<dt id="z-zone"><b>-z</b> <i>zone</i></dt>
<dd>

<p>set the zone to <i>zone</i> for output. Use either 0 &lt; <i>zone</i> &lt;= 60 for a UTM zone or <i>zone</i> = 0 for UPS. Alternatively use a <i>zone</i>+<i>hemisphere</i> designation, e.g., 38n. See <a href="#ZONE">&quot;ZONE&quot;</a>.</p>

</dd>
<dt id="s"><b>-s</b></dt>
<dd>

<p>use the standard UPS and UTM zones.</p>

</dd>
<dt id="t"><b>-t</b></dt>
<dd>

<p>similar to <b>-s</b> but forces UPS regions to the closest UTM zone.</p>

</dd>
<dt id="S-or--T"><b>-S</b> or <b>-T</b></dt>
<dd>

<p>behave the same as <b>-s</b> and <b>-t</b>, respectively, until the first legal conversion is performed. For subsequent points, the zone and hemisphere of that conversion are used. This enables a sequence of points to be converted into UTM or UPS using a consistent coordinate system.</p>

</dd>
<dt id="n"><b>-n</b></dt>
<dd>

<p>on input, MGRS coordinates refer to the south-west corner of the MGRS square instead of the center; see <a href="#MGRS">&quot;MGRS&quot;</a>.</p>

</dd>
<dt id="w"><b>-w</b></dt>
<dd>

<p>toggle the longitude first flag (it starts off); if the flag is on, then on input and output, longitude precedes latitude (except that, on input, this can be overridden by a hemisphere designator, <i>N</i>, <i>S</i>, <i>E</i>, <i>W</i>).</p>

</dd>
<dt id="p-prec"><b>-p</b> <i>prec</i></dt>
<dd>

<p>set the output precision to <i>prec</i> (default 0); <i>prec</i> is the precision relative to 1 m. See <a href="#PRECISION">&quot;PRECISION&quot;</a>.</p>

</dd>
<dt id="l"><b>-l</b></dt>
<dd>

<p>on output, UTM/UPS uses the long forms <i>north</i> and <i>south</i> to designate the hemisphere instead of <i>n</i> or <i>s</i>.</p>

</dd>
<dt id="a"><b>-a</b></dt>
<dd>

<p>on output, UTM/UPS uses the abbreviations <i>n</i> and <i>s</i> to designate the hemisphere instead of <i>north</i> or <i>south</i>; this is the default representation.</p>

</dd>
<dt id="comment-delimiter-commentdelim"><b>--comment-delimiter</b> <i>commentdelim</i></dt>
<dd>

<p>set the comment delimiter to <i>commentdelim</i> (e.g., &quot;#&quot; or &quot;//&quot;). If set, the input lines will be scanned for this delimiter and, if found, the delimiter and the rest of the line will be removed prior to processing and subsequently appended to the output line (separated by a space).</p>

</dd>
<dt id="version"><b>--version</b></dt>
<dd>

<p>print version and exit.</p>

</dd>
<dt id="h"><b>-h</b></dt>
<dd>

<p>print usage and exit.</p>

</dd>
<dt id="help"><b>--help</b></dt>
<dd>

<p>print full documentation and exit.</p>

</dd>
<dt id="input-file-infile"><b>--input-file</b> <i>infile</i></dt>
<dd>

<p>read input from the file <i>infile</i> instead of from standard input; a file name of &quot;-&quot; stands for standard input.</p>

</dd>
<dt id="input-string-instring"><b>--input-string</b> <i>instring</i></dt>
<dd>

<p>read input from the string <i>instring</i> instead of from standard input. All occurrences of the line separator character (default is a semicolon) in <i>instring</i> are converted to newlines before the reading begins.</p>

</dd>
<dt id="line-separator-linesep"><b>--line-separator</b> <i>linesep</i></dt>
<dd>

<p>set the line separator character to <i>linesep</i>. By default this is a semicolon.</p>

</dd>
<dt id="output-file-outfile"><b>--output-file</b> <i>outfile</i></dt>
<dd>

<p>write output to the file <i>outfile</i> instead of to standard output; a file name of &quot;-&quot; stands for standard output.</p>

</dd>
</dl>

<h1 id="PRECISION">PRECISION</h1>

<p><i>prec</i> gives precision of the output with <i>prec</i> = 0 giving 1 m precision, <i>prec</i> = 3 giving 1 mm precision, etc. <i>prec</i> is the number of digits after the decimal point for UTM/UPS. For MGRS, The number of digits per coordinate is 5 + <i>prec</i>; <i>prec</i> = -6 results in just the grid zone. For decimal degrees, the number of digits after the decimal point is 5 + <i>prec</i>. For DMS (degree, minute, seconds) output, the number of digits after the decimal point in the seconds components is 1 + <i>prec</i>; if this is negative then use minutes (<i>prec</i> = -2 or -3) or degrees (<i>prec</i> &lt;= -4) as the least significant component. Print convergence, resp. scale, with 5 + <i>prec</i>, resp. 7 + <i>prec</i>, digits after the decimal point. The minimum value of <i>prec</i> is -5 (-6 for MGRS) and the maximum is 9 for UTM/UPS, 9 for decimal degrees, 10 for DMS, 6 for MGRS, and 8 for convergence and scale.</p>

<h1 id="GEOGRAPHIC-COORDINATES">GEOGRAPHIC COORDINATES</h1>

<p>The utility accepts geographic coordinates, latitude and longitude, in a number of common formats. Latitude precedes longitude, unless the <b>-w</b> option is given which switches this convention. On input, either coordinate may be given first by appending or prepending <i>N</i> or <i>S</i> to the latitude and <i>E</i> or <i>W</i> to the longitude. These hemisphere designators carry an implied sign, positive for <i>N</i> and <i>E</i> and negative for <i>S</i> and <i>W</i>. This sign multiplies any +/- sign prefixing the coordinate. The coordinates may be given as decimal degree or as degrees, minutes, and seconds. d, &#39;, and &quot; are used to denote degrees, minutes, and seconds, with the least significant designator optional. (See <a href="#QUOTING">&quot;QUOTING&quot;</a> for how to quote the characters &#39; and &quot; when entering coordinates on the command line.) Alternatively, : (colon) may be used to separate the various components. Only the final component of coordinate can include a decimal point, and the minutes and seconds components must be less than 60.</p>

<p>It is also possible to carry out addition or subtraction operations in geographic coordinates. If the coordinate includes interior signs (i.e., not at the beginning or immediately after an initial hemisphere designator), then the coordinate is split before such signs; the pieces are parsed separately and the results summed. For example the point 15&quot; east of 39N 70W is</p>

<pre><code>    39N 70W+0:0:15E</code></pre>

<p><b>WARNING:</b> &quot;Exponential&quot; notation is not recognized for geographic coordinates. Thus 7.0E1 is illegal, while 7.0E+1 is parsed as (7.0E) + (+1), yielding the same result as 8.0E.</p>

<p>Various unicode characters (encoded with UTF-8) may also be used to denote degrees, minutes, and seconds, e.g., the degree, prime, and double prime symbols; in addition two single quotes can be used to represent &quot;.</p>

<p>The other GeographicLib utilities use the same rules for interpreting geographic coordinates; in addition, azimuths and arc lengths are interpreted the same way.</p>

<h1 id="QUOTING">QUOTING</h1>

<p>Unfortunately the characters &#39; and &quot; have special meanings in many shells and have to be entered with care. However note (1) that the trailing designator is optional and that (2) you can use colons as a separator character. Thus 10d20&#39; can be entered as 10d20 or 10:20 and 10d20&#39;30&quot; can be entered as 10:20:30.</p>

<dl>

<dt id="Unix-shells-sh-bash-tsch">Unix shells (sh, bash, tsch)</dt>
<dd>

<p>The characters &#39; and &quot; can be quoted by preceding them with a \ (backslash); or you can quote a string containing &#39; with a pair of &quot;s. The two alternatives are illustrated by</p>

<pre><code>   echo 10d20\&#39;30\&quot; &quot;20d30&#39;40&quot; | GeoConvert -d -p -1
   =&gt; 10d20&#39;30&quot;N 020d30&#39;40&quot;E</code></pre>

<p>Quoting of command line arguments is similar</p>

<pre><code>   GeoConvert -d -p -1 --input-string &quot;10d20&#39;30\&quot; 20d30&#39;40&quot;
   =&gt; 10d20&#39;30&quot;N 020d30&#39;40&quot;E</code></pre>

</dd>
<dt id="Windows-command-shell-cmd">Windows command shell (cmd)</dt>
<dd>

<p>The &#39; character needs no quoting; the &quot; character can either be quoted by a ^ or can be represented by typing &#39; twice. (This quoting is usually unnecessary because the trailing designator can be omitted.) Thus</p>

<pre><code>   echo 10d20&#39;30&#39;&#39; 20d30&#39;40 | GeoConvert -d -p -1
   =&gt; 10d20&#39;30&quot;N 020d30&#39;40&quot;E</code></pre>

<p>Use \ to quote the &quot; character in a command line argument</p>

<pre><code>   GeoConvert -d -p -1 --input-string &quot;10d20&#39;30\&quot; 20d30&#39;40&quot;
   =&gt; 10d20&#39;30&quot;N 020d30&#39;40&quot;E</code></pre>

</dd>
<dt id="Input-from-a-file">Input from a file</dt>
<dd>

<p>No quoting need be done if the input from a file. Thus each line of the file <code>input.txt</code> should just contain the plain coordinates.</p>

<pre><code>  GeoConvert -d -p -1 &lt; input.txt</code></pre>

</dd>
</dl>

<h1 id="MGRS">MGRS</h1>

<p>MGRS coordinates represent a square patch of the earth, thus <code>38SMB4488</code> is in zone <code>38n</code> with 444km &lt;= <i>easting</i> &lt; 445km and 3688km &lt;= <i>northing</i> &lt; 3689km. Consistent with this representation, coordinates are <i>truncated</i> (instead of <i>rounded</i>) to the requested precision. Similarly, on input an MGRS coordinate represents the <i>center</i> of the square (<code>38n 444500 3688500</code> in the example above). However, if the <b>-n</b> option is given then the south-west corner of the square is returned instead (<code>38n 444000 3688000</code> in the example above).</p>

<h1 id="ZONE">ZONE</h1>

<p>If the input is <b>geographic</b>, <b>GeoConvert</b> uses the standard rules of selecting UTM vs UPS and for assigning the UTM zone (with the Norway and Svalbard exceptions). If the input is <b>UTM/UPS</b> or <b>MGRS</b>, then the choice between UTM and UPS and the UTM zone mirrors the input. The <b>-z</b> <i>zone</i>, <b>-s</b>, and <b>-t</b> options allow these rules to be overridden with <i>zone</i> = 0 being used to indicate UPS. For example, the point</p>

<pre><code>   79.9S 6.1E</code></pre>

<p>corresponds to possible MGRS coordinates</p>

<pre><code>   32CMS4324728161 (standard UTM zone = 32)
   31CEM6066227959 (neighboring UTM zone = 31)
     BBZ1945517770 (neighboring UPS zone)</code></pre>

<p>then</p>

<pre><code>   echo 79.9S 6.1E      | GeoConvert -p -3 -m       =&gt; 32CMS4328
   echo 31CEM6066227959 | GeoConvert -p -3 -m       =&gt; 31CEM6027
   echo 31CEM6066227959 | GeoConvert -p -3 -m -s    =&gt; 32CMS4328
   echo 31CEM6066227959 | GeoConvert -p -3 -m -z 0  =&gt;   BBZ1917</code></pre>

<p>Is <i>zone</i> is specified with a hemisphere, then this is honored when printing UTM coordinates:</p>

<pre><code>   echo -1 3 | GeoConvert -u         =&gt; 31s 500000 9889470
   echo -1 3 | GeoConvert -u -z 31   =&gt; 31s 500000 9889470
   echo -1 3 | GeoConvert -u -z 31s  =&gt; 31s 500000 9889470
   echo -1 3 | GeoConvert -u -z 31n  =&gt; 31n 500000 -110530</code></pre>

<p><b>NOTE</b>: the letter in the zone specification for UTM is a hemisphere designator <i>n</i> or <i>s</i> and <i>not</i> an MGRS latitude band letter. Convert the MGRS latitude band letter to a hemisphere as follows: replace <i>C</i> thru <i>M</i> by <i>s</i> (or <i>south</i>); replace <i>N</i> thru <i>X</i> by <i>n</i> (or <i>north</i>).</p>

<h1 id="EXAMPLES">EXAMPLES</h1>

<pre><code>   echo 38SMB4488 | GeoConvert         =&gt; 33.33424 44.40363
   echo 38SMB4488 | GeoConvert -: -p 1 =&gt; 33:20:03.25N 044:2413.06E
   echo 38SMB4488 | GeoConvert -u      =&gt; 38n 444500 3688500
   echo E44d24 N33d20 | GeoConvert -m -p -3 =&gt; 38SMB4488</code></pre>

<p>GeoConvert can be used to do simple arithmetic using degree, minutes, and seconds. For example, sometimes data is tiled in 15 second squares tagged by the DMS representation of the SW corner. The tags of the tile at 38:59:45N 077:02:00W and its 8 neighbors are then given by</p>

<pre><code>    t=0:0:15
    for y in -$t +0 +$t; do
        for x in -$t +0 +$t; do
            echo 38:59:45N$y 077:02:00W$x
        done
    done | GeoConvert -: -p -1 | tr -d &#39;: &#39;
    =&gt;
    385930N0770215W
    385930N0770200W
    385930N0770145W
    385945N0770215W
    385945N0770200W
    385945N0770145W
    390000N0770215W
    390000N0770200W
    390000N0770145W</code></pre>

<h1 id="ERRORS">ERRORS</h1>

<p>An illegal line of input will print an error message to standard output beginning with <code>ERROR:</code> and causes <b>GeoConvert</b> to return an exit code of 1. However, an error does not cause <b>GeoConvert</b> to terminate; following lines will be converted.</p>

<h1 id="ABBREVIATIONS">ABBREVIATIONS</h1>

<dl>

<dt id="UTM"><b>UTM</b></dt>
<dd>

<p>Universal Transverse Mercator, <a href="https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system">https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system</a>.</p>

</dd>
<dt id="UPS"><b>UPS</b></dt>
<dd>

<p>Universal Polar Stereographic, <a href="https://en.wikipedia.org/wiki/Universal_Polar_Stereographic">https://en.wikipedia.org/wiki/Universal_Polar_Stereographic</a>.</p>

</dd>
<dt id="MGRS1"><b>MGRS</b></dt>
<dd>

<p>Military Grid Reference System, <a href="https://en.wikipedia.org/wiki/Military_grid_reference_system">https://en.wikipedia.org/wiki/Military_grid_reference_system</a>.</p>

</dd>
<dt id="WGS84"><b>WGS84</b></dt>
<dd>

<p>World Geodetic System 1984, <a href="https://en.wikipedia.org/wiki/WGS84">https://en.wikipedia.org/wiki/WGS84</a>.</p>

</dd>
</dl>

<h1 id="SEE-ALSO">SEE ALSO</h1>

<p>An online version of this utility is availbable at <a href="https://geographiclib.sourceforge.io/cgi-bin/GeoConvert">https://geographiclib.sourceforge.io/cgi-bin/GeoConvert</a>.</p>

<p>The algorithms for the transverse Mercator projection are described in C. F. F. Karney, <i>Transverse Mercator with an accuracy of a few nanometers</i>, J. Geodesy <b>85</b>(8), 475-485 (Aug. 2011); DOI <a href="https://doi.org/10.1007/s00190-011-0445-3">https://doi.org/10.1007/s00190-011-0445-3</a>; preprint <a href="https://arxiv.org/abs/1002.1417">https://arxiv.org/abs/1002.1417</a>.</p>

<h1 id="AUTHOR">AUTHOR</h1>

<p><b>GeoConvert</b> was written by Charles Karney.</p>

<h1 id="HISTORY">HISTORY</h1>

<p><b>GeoConvert</b> was added to GeographicLib, <a href="https://geographiclib.sourceforge.io">https://geographiclib.sourceforge.io</a>, in 2009-01.</p>


</body>

</html>


